//
//  dengluViewController.m
//  豆瓣
//
//  Created by dlios on 15-1.5-18.
//  Copyright (c) 2015年 ClearLove.com All rights reserved.//

#import "dengluViewController.h"
#import "LView.h"
#import "BBBViewController.h"

@interface dengluViewController ()

@end

@implementation dengluViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"用户登录";
//    self.navigationController.navigationBar.hidden = NO;
    
    [self denglu];
    
}
- (void)denglu
{
    LView *l1 = [[LView alloc] initWithFrame:CGRectMake(20, 90, self.view.frame.size.width - 40, 60)];
    l1.label.text = @"用户名";
    l1.textField.placeholder = @"请输入用户名";
    l1.textField.tag = 1000;
    [self.view addSubview:l1];
    [l1 release];
    
    LView *l2 = [[LView alloc] initWithFrame:CGRectMake(20, 170, self.view.frame.size.width - 40, 60)];
    l2.label.text = @"密码";
    l2.textField.placeholder = @"请输入密码";
    l2.textField.tag = 2000;
    [self.view addSubview:l2];
    [l2 release];
    
    UIButton *b1 = [UIButton buttonWithType:UIButtonTypeSystem];
    b1.backgroundColor = [UIColor groupTableViewBackgroundColor];
    b1.frame = CGRectMake(30, 250, 130, 40);
    [b1 setTitle:@"登录" forState:UIControlStateNormal];
    [b1 addTarget:self action:@selector(jinru:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:b1];
    
    UIButton *b2 = [UIButton buttonWithType:UIButtonTypeSystem];
    b2.backgroundColor = [UIColor orangeColor];
    b2.frame = CGRectMake(200, 250, 130, 40);
    [b2 setTitle:@"注册" forState:UIControlStateNormal];
    [b2 addTarget:self action:@selector(zhuce:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:b2];
    
    
}
- (void)jinru:(UIButton *)a
{
    UITextField *s1 = (UITextField *)[self.view viewWithTag:1000];
    UITextField *s2 = (UITextField *)[self.view viewWithTag:2000];
    if ([s1.text isEqualToString:@""] || [s2.text isEqualToString:@""]) {
        UIAlertView *al1 = [[UIAlertView alloc] initWithTitle:@"提示" message:@"用户名和密码不能为空" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [al1 show];
        [al1 release];
    }else
        if (![s1.text isEqualToString:@"sjq"] || ![s2.text isEqualToString:@"123456"]) {
            UIAlertView *al2 = [[UIAlertView alloc] initWithTitle:@"提示" message:@"用户名或密码错误" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
            [al2 show];
            [al2 release];
        }else{
            UIAlertView *al3 = [[UIAlertView alloc] initWithTitle:@"提示" message:@"欢迎回来" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
            [al3 show];
            [al3 release];
        }
    
}
- (void)zhuce:(UIButton *)b
{
    BBBViewController *a = [[BBBViewController alloc] init];
    [self.navigationController pushViewController:a animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
